﻿#建议保存编码为：bom头 + utf8
param
(
	[parameter(Mandatory = $true)]
	[ValidateNotNullOrEmpty()]
	[String]$prefix,

	[parameter(Mandatory = $true)]
	[ValidateNotNullOrEmpty()]
	[String[]]$domains,

	[parameter(Mandatory = $true)]
	[ValidateNotNullOrEmpty()]
	[Alias("cname")][String]$cluster名
)

$prefix2 = $prefix.Replace('/','_')
if (Test-Path -LiteralPath "${PSScriptRoot}/prefix/${prefix2}")
{
	& "${PSScriptRoot}/Write-Error2.ps1"  '错误：已经有此http路径。退出码1'
	exit 1
}

foreach ($temp011 in $domains)
{
	if (Test-Path -LiteralPath "${PSScriptRoot}/domains/${temp011}")
	{
		& "${PSScriptRoot}/Write-Error2.ps1"  '错误：已经有此http域名。退出码2'
		exit 2
	}
}

$private:rds = Get-Content -LiteralPath "${PSScriptRoot}/rds.json" | ConvertFrom-Json -Depth 99
foreach ($temp001 in $private:rds.resources[0].virtual_hosts[0])
{
	if ($temp001.'routes'.'route'.'cluster' -eq $cluster名)
	{
		& "${PSScriptRoot}/Write-Error2.ps1"  '错误：已经有此cluster名。退出码3'
		exit 3
	}
}

exit 0
